<?php

class Community_BookCommentController extends Zend_Controller_Action
{

    public function init()
    {
        // Khởi tạo các thẻ [Lĩnh vực tìm kiếm]
        $category=new Admin_Model_MCategory();
        $bookCategory=$category->getAllCategories(array("_id","name"));
        $this->view->category=$bookCategory;        

        // Cài đặt thông tin đăng nhập
        $mySession=new Zend_Session_Namespace();
        if(isset ($mySession->uid) && isset($mySession->username))
        {
            $this->view->username=$mySession->username;
            $this->view->uid=$mySession->uid;

            $userModel=new Personal_Model_MUser();
            $this->view->userinfo=$userModel->getInfoBasic($mySession->uid);
        }
        
    }

    public function indexAction()
    {
        $this->_helper->layout()->setLayout('layout_community');

        $currentpage=(int)$this->getRequest()->getParam('currentpage',1);
        $pagesize=10;

        $commentModel=new Community_Model_MBookComment();

        $comment=$commentModel->getComments($total, $currentpage, $pagesize);
        $this->view->total=$total;
        if($total>0)
        {
            $this->view->comment=$comment;
            $this->view->currentpage=$currentpage;
            $this->view->pagesize=$pagesize;
        }
    }
}

